/*
 * @Author: szx
 * @Date: 2022-03-09 14:49:41
 * @LastEditTime: 2022-03-09 14:59:10
 * @Description:
 * @FilePath: \leetcode\1500-1599\1588\1588.js
 */
/**
 * @param {number[]} arr
 * @return {number}
 */
var sumOddLengthSubarrays = function (arr) {
    let sum = 0;
    const preSum = arr.map((v) => (sum += v));
    let res = 0;
    for (let i = 0; i < arr.length; i++) {
        for (let j = i; j < arr.length; j += 2) {
            res += preSum[j] - preSum[i] + arr[i];
        }
    }
    return res;
};
console.log(sumOddLengthSubarrays([1, 4, 2, 5, 3]));
console.log(sumOddLengthSubarrays([1, 2]));
console.log(sumOddLengthSubarrays([10, 11, 12]));
